package lt.liepasoft.locr.realization;

import java.util.List;

import lt.liepasoft.locr.ImageManager;
import lt.liepasoft.locr.Ocr;
import lt.liepasoft.locr.Recognizer;
import lt.liepasoft.locr.Scanner;
import lt.liepasoft.locr.data.Bounds;
import lt.liepasoft.locr.data.OcrImage;
import lt.liepasoft.locr.data.RgbImage;
import lt.liepasoft.locr.data.Symbol;

public class LiepaOCR extends Ocr {
        
    private Scanner scanner;
    private Recognizer recognizer;

    public LiepaOCR() {
        scanner = new FloodFillScanner();
        recognizer = new SymbolRecognizer();
    }
    
    
    @Override
    protected OcrImage processImage(RgbImage image, Bounds bounds) {
        return ImageManager.createOcrImage(image, true);
    }

    @Override
    protected List<Symbol> findSymbols(OcrImage image, Bounds bounds) {
        return scanner.scan(image, bounds);
    }

    @Override
    protected String recognizeSymbols(List<Symbol> symbols) {
        String text = "";
        for (int i=0; i<symbols.size(); i++){
            text += recognizer.recognize(symbols.get(i).getImage());
        }
        return text;
    }
    
}
